<template>
  <div>
    <el-dialog
      destroy-on-close
      :title="title"
      :visible.sync="visible"
      :close-on-click-modal="false"
      width="800px"
      @close="onClose"
    >
      <el-button type="primary" @click="onSubmit">确定</el-button>
      <el-table
        v-loading="loading"
        :data="tableData"
        element-loading-background="rgba(0, 0, 0, 0.8)"
        height="550"
        stripe
        border
        style="width: 100%"
        @selection-change="SelectionChange"
      >
        >
        <!-- <el-table-column label="操作" width="50" fixed>
          <template slot-scope="scope">
            <span class="edit-tooltip">
              <el-tooltip effect="dark" content="选择" placement="bottom">
                <el-button type="text" @click="onChoose(scope.row)">
                  <svg-icon style="fill: #ff4e1d" icon-class="choose"></svg-icon>
                </el-button>
              </el-tooltip>
            </span>
          </template>
        </el-table-column> -->
        <el-table-column type="selection" width="55" align="center"> </el-table-column>
        <el-table-column :resizable="false" type="index" width="50" label="序号" align="center" />
        <el-table-column :resizable="false" prop="dutycode" label="编号" min-width="120" />
        <el-table-column :resizable="false" prop="dutyname" label="名称" min-width="120" />
        <el-table-column :resizable="false" prop="describe" label="备注" min-width="180" />
      </el-table>
      <!-- <el-pagination
        style="margin: 10px"
        @size-change="sizeChange"
        @current-change="pageChange"
        :current-page="queryForm.pagenum"
        :page-sizes="[10, 50, 100]"
        :page-size="queryForm.pagesize"
        background
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      /> -->
    </el-dialog>
  </div>
</template>

<script>
import { QueryPageList } from '@/api/settings/gangwei'
export default {
  props: ['visiblesgw'],

  data() {
    return {
      queryForm: {
        // pagenum: 1,
        // pagesize: 10
      },
      total: 0,
      tableData: [],
      visible: this.visiblesgw,
      SelectionData: [],
      title: '岗位选择'
    }
  },
  // 这里用watch方法来监听父组件传过来的值，来实现实时更新
  watch: {
    visiblesgw(val) {
      // message即为父组件的值，val参数为值
      this.visible = val // 将父组件的值赋给childrenMessage 子组件的值
    }
  },
  created() {
    this.onSearch()
  },
  methods: {
    // // 点击页面显示条数
    // sizeChange(size) {
    //   this.queryForm.pagesize = size
    //   this.onSearch()
    // },
    // // 点击下一页与页码
    // pageChange(page) {
    //   console.log(page)
    //   this.queryForm.pagenum = page
    //   this.onSearch()
    // },
    // 查询数据
    async onSearch() {
      this.loading = true
      const { content } = await QueryPageList(this.queryForm)
      console.log(content)
      this.tableData = content.list
      this.total = content.total
      this.loading = false
    },
    // 点击关闭给父组件传值
    onClose() {
      this.$emit('fathergw')
    },
    SelectionChange(val) {
      this.SelectionData = val
    },
    // 点击对勾给父组件传值
    onSubmit() {
      console.log(this.SelectionData)
      this.$emit('onChoosegw', this.SelectionData)
      this.$emit('fathergw')
    }
  }
}
</script>

<style scoped>
.el-button {
  padding-bottom: 10px;
}
</style>
